home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / GETDOWNL.MOD < prev    next >
Text File  |  1987-09-08  |  7KB  |  205 lines

  1. (*----------------------------------------------------------------------*)
  2. (*        Get_Download_Protocol --- Get File Transfer Protocol          *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Get_Download_Protocol : Transfer_Type ;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Function:   Get_Download_Protocol                                *)
  10. (*                                                                      *)
  11. (*     Purpose:    Gets file name and transfer protocol for download.   *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Transtyp := Get_Download_Protocol: Transfer_Type;             *)
  16. (*                                                                      *)
  17. (*     Remarks:                                                         *)
  18. (*                                                                      *)
  19. (*     Calls:    KeyPressed                                             *)
  20. (*               Async_Send                                             *)
  21. (*               Async_Receive                                          *)
  22. (*                                                                      *)
  23. (*----------------------------------------------------------------------*)
  24.  
  25. CONST
  26.    Ascii_Quit_Item = 4;
  27.  
  28. VAR
  29.    Transfer_Kind : Transfer_Type;
  30.    Ascii_Menu    : Menu_Type;
  31.    I             : INTEGER;
  32.    Pacing_String : STRING[1];
  33.    OK_File_Name  : BOOLEAN;
  34.    Flag          : BOOLEAN;
  35.    IY            : INTEGER;
  36.    AFile         : FILE;
  37.  
  38. (*----------------------------------------------------------------------*)
  39.  
  40. FUNCTION Yes_No_String( B: BOOLEAN ) : AnyStr;
  41.  
  42. BEGIN (* Yes_No_String *)
  43.  
  44.    IF B THEN
  45.       Yes_No_String := 'YES'
  46.    ELSE
  47.       Yes_No_String := 'NO';
  48.  
  49. END   (* Yes_No_String *);
  50.  
  51. (*----------------------------------------------------------------------*)
  52.  
  53. PROCEDURE Get_Ascii_Parameters;
  54.  
  55. VAR
  56.    Ascii_Done : BOOLEAN;
  57.    I          : INTEGER;
  58.    J          : INTEGER;
  59.    Local_Save : Saved_Screen_Ptr;
  60.  
  61. BEGIN (* Get_Ascii_Parameters *)
  62.  
  63.    Make_A_Menu( Ascii_Menu, Ascii_Quit_Item, 3, 10, 50, 21, Ascii_Quit_Item,
  64.                 'Ascii transfer parameters: ',
  65.                 ';;;Perform transfer;', TRUE );
  66.  
  67.    Ascii_Done := FALSE;
  68.  
  69.    REPEAT
  70.  
  71.       FOR I := 1 TO ( Ascii_Quit_Item - 1 ) DO
  72.          WITH Ascii_Menu.Menu_Entries[I] DO
  73.             CASE I OF
  74.  
  75.                1:  Menu_Item_Text := 'a) Ctrl-Z marks end of file (now ' +
  76.                                      Yes_No_String( Ascii_Use_CtrlZ ) + ')';
  77.  
  78.                2:  Menu_Item_Text := 'b) Display text transferred (now ' +
  79.                                      Yes_No_String( Ascii_Show_Text ) + ')';
  80.  
  81.                3:  Menu_Item_Text := 'c) Translate incoming text (now ' +
  82.                                      Yes_No_String( Ascii_Translate ) + ')';
  83.  
  84.             END (* CASE *);
  85.  
  86.       Menu_Display_Choices( Ascii_Menu );
  87.  
  88.       I := Menu_Get_Choice( Ascii_Menu , Dont_Erase_Menu );
  89.  
  90.       CASE I OF
  91.  
  92.          1    : Ascii_Use_CtrlZ  := NOT Ascii_Use_CtrlZ;
  93.  
  94.          2    : Ascii_Show_Text  := NOT Ascii_Show_Text;
  95.  
  96.          3    : Ascii_Translate  := NOT Ascii_Translate;
  97.  
  98.          ELSE
  99.             Ascii_Done := TRUE;
  100.  
  101.       END (* CASE *);
  102.  
  103.    UNTIL ( Ascii_Done );
  104.                                    (* Remove this window            *)
  105.    Restore_Screen( Saved_Screen );
  106.    Reset_Global_Colors;
  107.  
  108. END   (* Get_Ascii_Parameters *);
  109.  
  110. (*----------------------------------------------------------------------*)
  111.  
  112. BEGIN (* Get_Download_Protocol *)
  113.                                    (* Copy keyboard data before we screw *)
  114.                                    (* it up so we can get file name      *)
  115.  
  116.    Saved_Kbd_File_Name := Keyboard_Line;
  117.  
  118.                                    (* Display menu of transfer types *)
  119.                                    (* and get transfer kind.         *)
  120.  
  121.    Display_Transfer_Types( 'receive' , Transfer_Kind );
  122.  
  123.                                    (* Get file name to use if not *)
  124.                                    (* batch transfer              *)
  125.    Ok_File_Name := FALSE;
  126.    FileName[0]  := #0;
  127.  
  128.    IF Single_File_Protocol[Transfer_Kind] THEN
  129.       BEGIN
  130.  
  131.          IF Auto_Find_FileNames THEN
  132.             Get_Auto_File_Name( Saved_Kbd_File_Name , FileName );
  133.  
  134.          REPEAT
  135.  
  136.             FOR I := 18 TO 20 DO
  137.                BEGIN
  138.                   GoToXY( 1 , I );
  139.                   ClrEol;
  140.                END;
  141.  
  142.             GoToXY( 2 , 18 );
  143.             WRITE('Enter Filename.Ext: ');
  144.  
  145.             GoToXY( 2 , 19 );
  146.             WRITE('>');
  147.             Read_Edited_String(FileName);
  148.             WRITELN;
  149.  
  150.             IF ( POS( ':' , FileName ) = 0 ) AND
  151.                ( POS( '\' , FileName ) = 0 ) THEN
  152.                Saved_Kbd_File_Name := Download_Dir_Path + FileName
  153.             ELSE
  154.                Saved_Kbd_File_Name := FileName;
  155.  
  156.             ASSIGN(AFile,Saved_Kbd_File_Name);
  157.                (*$I- *)
  158.             RESET( AFile );
  159.                (*$I+ *)
  160.  
  161.             IF Int24Result <> 0 THEN
  162.                OK_File_Name := TRUE
  163.             ELSE
  164.                BEGIN
  165.                   OK_File_Name := YesNo( Saved_Kbd_File_Name + ' exists, overwrite (Y/N) ? ');
  166.                      (*$I-*)
  167.                   CLOSE( AFile );
  168.                      (*$I+*)
  169.                END;
  170.  
  171.          UNTIL( OK_File_Name );
  172.  
  173.          ASSIGN( AFile, Saved_Kbd_File_Name );
  174.                (*$I- *)
  175.          REWRITE( AFile );
  176.                (*$I+ *)
  177.  
  178.          IF Int24Result <> 0 THEN
  179.             BEGIN
  180.                Transfer_Kind := None;
  181.                WRITE('*** Can''t open file, receive cancelled ***');
  182.                DELAY( Two_Second_Delay );
  183.             END;
  184.  
  185.             (*$I-*)
  186.          CLOSE( AFile );
  187.             (*$I+*)
  188.  
  189.          I := INT24Result;
  190.  
  191.       END  (* Get file name *);
  192.                                    (* Remove this window            *)
  193.    Restore_Screen( Saved_Screen );
  194.    Reset_Global_Colors;
  195.  
  196.    Use_Time_Sent := Use_Block_Zero;
  197.  
  198.    IF ( Transfer_Kind = Ascii ) THEN
  199.       Get_Ascii_Parameters;
  200.                                    (* Return transfer protocol type *)
  201.  
  202.    Get_Download_Protocol := Transfer_Kind;
  203.  
  204. END   (* Get_Download_Protocol *);
  205.